package com.infonova.education.microservice.controller;

import com.infonova.education.microservice.repository.entity.Product;
import com.infonova.education.microservice.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Iterator;


@RestController
public class ProductController {

    @Autowired
    private ProductService productService;

    @RequestMapping("/")
    public String index() {
        return "Greetings from Spring Boot!";
    }

    @RequestMapping("/products")
    public Iterable<Product> allProducts() {
        return productService.getAllProducts();
    }

}
